Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-diff

Package Overview
Dependencies
Maintainers
7
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-diff

Display differences clearly so people can review changes confidently.

  • 26.6.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48M
increased by7.31%
Maintainers
7
Weekly downloads
 
Created

What is jest-diff?

The jest-diff npm package is a utility primarily used to show differences between two values, typically used in testing environments to assert the equality of objects, arrays, or other data structures. It is part of the Jest testing framework but can be used independently for its diffing capabilities.

What are jest-diff's main functionalities?

Diffing two values

This feature allows you to compare two JavaScript objects and outputs a string that visually represents the differences between them. It is useful for debugging and in test assertions to see what exactly differs when a test fails.

const diff = require('jest-diff');
const a = { a: { b: { c: 5 } } };
const b = { a: { b: { c: 6 } } };
console.log(diff(a, b));

Customizing diff output

This feature allows customization of the diff output by passing options. You can specify annotations for the compared values, which helps in making the output more understandable and tailored to specific needs.

const diff = require('jest-diff');
const options = { aAnnotation: 'First', bAnnotation: 'Second' };
const a = [1, 2, 3];
const b = [2, 1, 3];
console.log(diff(a, b, options));

Other packages similar to jest-diff

FAQs

Package last updated on 02 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc